package com.oocl.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.oocl.dao.BookOrderDao;
import com.oocl.pojo.GoodOrder;
import com.oocl.util.DBUtil;

public class BookOrderDaoImpl implements BookOrderDao {

	@Override
	public int addOrder(GoodOrder d) {
		String sql = "insert into GoodOrder(id, uuid, bookname, count) values (?,?,?,?)";
		
		PreparedStatement pst =null;
		Connection con = null;
		int m = 0; 
		
		try {
//			con =DBUtil.createConnectionByJNDI();
			con = DBUtil.createConnection();
			pst = con.prepareStatement(sql);
			pst.setString(1, d.getId());
			pst.setString(2, d.getUid());
			pst.setString(3, d.getBookName());
			pst.setInt(4, d.getCount());
			
			m = pst.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		finally{
			DBUtil.close(con, pst, null);
		}
		return m;

	}

}
